const http = require('http')
const serve = http.createServer()

serve.on('request', (req, res) => {
  let url = req.url
  let context = ''

  if (url === '/index' || url === '/') {
    context = "<h1>这是index页面</h1>"
  } else if (url === '/about') {
    context = "<h1>这是about页面</h1>"
  } else {
    context = "<h1>404 Not Found</h1>"
  }
  res.setHeader('Content-Type', 'text/html;charset=utf-8')

  res.end(context)
})

serve.listen(8088, () => {
  console.log('running')
})
